package fr.umlv.escape_ig.manager;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import fr.umlv.escape_ig.R;

/**
 * This class allows the display of objects
 */

// TODO refaire la classe por d'elle affiche des listes d'objets flyable

public class Display extends SurfaceView {

	private SurfaceHolder holder;

	private final Bitmap missile;
	private final Bitmap shiboleet;
	private final Bitmap fireball;
	private final Bitmap tsar;
	private final Bitmap ship;
	private final Bitmap ship2;

	public Display(Context context) {
		super(context);
		this.holder = getHolder();
		missile = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.iconmissile);
		shiboleet = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.iconshiboleet);
		fireball = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.iconfireball);
		tsar = BitmapFactory.decodeResource(context.getResources(),
				R.drawable.icontsar);
		ship = BitmapFactory.decodeResource(context.getResources(), R.drawable.ship);
		ship2 = BitmapFactory.decodeResource(context.getResources(), R.drawable.ship2);
		callback();
	}

	@Override
	public void onDraw(Canvas canvas) {

	}

	private void callback() {
	}

	public void displayIcon(Canvas canvas) {
		int width=0;
		canvas.save();
		canvas.drawBitmap(missile, width, 0, null);
		width+=missile.getWidth();
		canvas.restore();
		canvas.save();
		canvas.drawBitmap(shiboleet, width, 0, null);
		width+=shiboleet.getWidth();
		canvas.restore();
		canvas.save();
		canvas.drawBitmap(fireball, width, 0, null);
		width+=fireball.getWidth();
		canvas.restore();
		canvas.save();
		canvas.drawBitmap(tsar,width, 0, null);
		canvas.restore();
	}
	public void diplayVesselBuilder(Canvas canvas){
		int width=0;
		canvas.save();
		canvas.drawBitmap(ship, width, 0, null);
		width+=ship.getWidth();
		canvas.restore();
		canvas.save();
		canvas.drawBitmap(ship2, width, 0, null);
		width+=ship2.getWidth();
		canvas.restore();
	}
	
	public int getXShip1(){
		return ship.getWidth();
	}
	public int getXShip2(){
		return ship2.getWidth();
	}
	public int getYShip1(){
		return ship.getHeight();
	}
	public int getYShip2(){
		return ship.getHeight();
	}
}
